<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


</body>
<script>
    //函数表达式后面跟括号，表示立即执行
    var f1 = function(a) {
        console.log(a);
    }(1)

    function abc() {
        console("测试函数声明")
    };

    +

    function() {
        console.log("立即执行+");
    }();

    -

    function() {
        console.log("立即执行-");
    }();
    ~ function() {
        console.log("立即执行~");
    }();

    ! function() {
        console.log("立即执行!");
    }();
    //
    (function() {
        console.log("立即执行()");
    })();
    //
    (function() {
        console.log("立即执行(())");
    }());
    //
    void

    function() {
        console.log("立即执行void")
    }();
    //
    new function() {
        console.log("立即执行 new")
    }();

    /*测试*/

    var calculator = (function(cal) {
        var count = 5;

        function add(x, y) {
            return x + y;
        }

        function subtract(x, y) {
            return x - y;
        }
        return {
            add1: add,
            subtract1: subtract
        }
    })(calculator || {});

    var calculator = (function(cal) {
        cal.mod = function(x, y) {
            return x % y;
        }
        return cal;
    })(calculator || {});
    console.log("测试")
    console.log(calculator.add1(1, 4));
</script>

</html>